class SwitcherView extends egret.Sprite {//控制场景切换
	private static instance:SwitcherView;
	private startView:StartView;//进入显示页面
	private gameagentView:GameagentView;//游戏页面
	private cloneView:CloneView;//克隆页面
	private guangView:GuangGame;//广告
	public constructor() {
		super();
		this.init();
	};
	// 初始化项目
	private init(){
		this.gameagentView = new GameagentView();
		this.startView = new StartView();
		this.cloneView = new CloneView();
		this.addChild(this.startView);
		this.startView.init();
		this.addEventListener(ChangeEvent.CHANGE_EVENT,this.onChangeScene,this);//开始场景切换
	};
	// 开始游戏
	public start(){
		this.addEventListener(ChangeEvent.CHANGE_EVENT,this.onChangeScene,this);
	};
	public static getInstance():SwitcherView
	{
        if(SwitcherView.instance == null)
        {
            SwitcherView.instance = new SwitcherView();
        }  
        return SwitcherView.instance;
    };
	public onChangeScene(e:ChangeEvent)
    {
        e.obj.endView();
        this.removeChildren();
        switch (e.eventType)
        {
			case StartView.START_VIEW:
				this.startView = new StartView();
				this.startView.init();
				this.addChild(this.startView);
				break;
			case GameagentView.GAMEAGENT_VIEW:
				this.gameagentView = new GameagentView();
				this.gameagentView.init();
				this.addChild(this.gameagentView);
				break;	
			case CloneView.CLONEVIEW:
 				this.cloneView = new CloneView();
				this.cloneView.init();
				this.addChild(this.cloneView);
				break;
			case GuangGame.GUANGGAO:
 				this.guangView = new GuangGame();
				this.guangView.init();
				
				this.addChild(this.guangView);
				break;	
			default:
				break;	
        }
    };
}

